<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/hui/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/hui/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/hui/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/hui/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/hui/static/h-ui.admin/css/style.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/hui/lib/laypage/1.2/skin/laypage.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>领取人列表</title>
</head>
<body onload="orderlist(1)">
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 订单管理 <span class="c-gray en">&gt;</span> 订单列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<form class="dataform" id="orderlist_form">
	<div class="text-c">
		<button onclick="removeIframe()" class="btn btn-primary radius">关闭选项卡</button>
		<input type="text" name="reciveName" placeholder="姓名" style="width:180px" class="input-text">
		<input type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })" id="datemin" class="input-text Wdate" name="beginTime" style="width:120px;">
		-
		<input type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })" id="datemax" class="input-text Wdate" name="endTime" style="width:120px;">
		<button onclick="orderlist(1)" class="btn btn-success" type="button"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
	</div>
	</form>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
		<span class="l"> <a class="btn btn-primary radius" onclick="carder_add('添加领卡人','${base }/admin/receive')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加领卡人</a></span>
		<span class="l" style="margin-left: 20px"> <a class="btn btn-primary radius" onclick="exportReceiver()" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 导出领卡人</a></span>
		<!-- <span class="r">共有数据：<strong></strong> 条</span> --> 
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20">  <!-- <span class="r">共有数据：<strong></strong> 条</span> --> </div>
	<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
			<thead>
				<tr class="text-c">
					<th width="60">领取人</th>
					<th width="90">领取卡号的开始卡号</th>
					<th width="90">领取卡号的结束卡号</th>
					<th width="50">领取的卡的面额</th>
					<th width="50">数量</th>
					<th width="50">已使用数量</th>
					<th width="90">领取时间</th>
					<th width="60">操作</th>
				</tr>
			</thead>
			<tbody id="tbody" class="text-c">
				
			</tbody>
		</table>
		<div style="width: 100%;height:15px;"></div>
		<div id="page1" class="pager"></div>
	</div>
	<div id="detail" style="display:none">
	<table class="table table-striped table-bordered table-hover" data-search="true">
        <tr> 
            <td class="text-center"><b>编号</b></td>
            <td class="text-center"><b>起始卡号</b></td>
            <td class="text-center"><b>结束卡号</b></td>
            <td class="text-center"><b>面额</b></td>
            <td class="text-center"><b>总数量</b></td>
        </tr>
        <tr>
        	<td class="text-center" id="detail_id"></td>
        	<td class="text-center" id="sequenceBegin"></td>
        	<td class="text-center" id="sequenceEnd"></td>
        	<td class="text-center" id="facePrice"></td>
        	<td class="text-center" id="receiveCount"></td>
        </tr>
        <tr>
        	<td class="text-center"><b>领用人</b></td>
            <td class="text-center"><b>已使用</b></td>
            <td class="text-center"><b>未使用</b></td>
            <td class="text-center"><b>未激活</b></td>
            <td class="text-center"><b>领卡时间</b></td>
        </tr>
        <tr>
        	<td class="text-center" id="receiveName"></td>
        	<td class="text-center" id="useCards"></td>
        	<td class="text-center" id="notUses"></td>
        	<td class="text-center" id="notActivation"></td>
        	<td class="text-center" id="sequenceTime"></td>
        </tr>
        <tr>
        	<td class="text-center"><b>接入端口token</b></td>
            <td class="text-center"><b>接入端口appkey</b></td>
            <td class="text-center"><b>接入端口appsecret</b></td>
            <td class="text-center"><b>接入端口phone</b></td>
            <td class="text-center"><b>操作</b></td>
        </tr>
        <tr>
        	<td class="text-center" id="portToken" ></td>
        	<td class="text-center" id="portAppkey"></td>
        	<td class="text-center" id="portAppsecret"></td>
        	<td class="text-center" id="portPhone"></td>
        	<td class="text-center" id="portUpdate"></td>
        </tr>
        <tr>
        	<td class="text-center"><b>接入端口url</b></td>
            <td class="text-center"><b></b></td>
            <td class="text-center"><b></b></td>
            <td class="text-center"><b></b></td>
            <td class="text-center"><b></b></td>
        </tr>
        <tr>
        	<td class="text-center" id="portUrl"></td>
        	<td class="text-center" id="">&nbsp;</td>
        	<td class="text-center" id="">&nbsp;</td>
        	<td class="text-center" id="">&nbsp;</td>
        	<td class="text-center" id="">&nbsp;</td>
        </tr>
	</table>
</div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="${pageContext.request.contextPath}/static/hui/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath}/static/hui/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/hui/static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath}/static/hui/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="${pageContext.request.contextPath}/static/hui/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<!-- <script type="text/javascript" src="${pageContext.request.contextPath}/static/hui/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>  -->
<script type="text/javascript" src="${pageContext.request.contextPath}/static/hui/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/hui/receives.js"></script>
<script type="text/javascript">
/*领卡人-添加*/
function carder_add(title,url){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}

function exportReceiver(){
	//var data = $("#orderlist_form").serializeArray();
	var a = document.createElement('a');
	var data = $("#orderlist_form").serialize();
	debugger;
	var url = '${pageContext.request.contextPath}/admin/exportReceiver?'+ data;
	a.href=url;
	a.click();
	
}

	function orderlist(pageNum){

		var reciveName = $("input[name=reciveName]").val();
		var beginTime = $("input[name=beginTime]").val();
		var endTime = $("input[name=endTime]").val();
		// '"beginTime":"'+beginTime+'","endTime":"'+endTime+'","customerName":"'+customerName+'"';
		var str ='"reciveName":"'+reciveName+'","beginTime":"'+beginTime+'","endTime":"'+endTime+'"';
		var url  = "${base}/admin/receiveAll";
		//引入core.js中的方法进行分页
		core.getUserListByPage(pageNum,str,url);
        return false;
	}
	/*  激活 */ 
	 function activate(sequenceBegin,sequenceEnd){
		 layer.confirm('确定要激活这些卡号吗?', {icon: 3, title:'提示'}, function(index){
				layer.close(index);
			  $.ajax({
					url :"${base}/admin/cardReceive/activateCard",
					type : 'post',
					dataType : 'json',
					data :{"sequenceBegin":sequenceBegin,"sequenceEnd":sequenceEnd},
					success : function(res) {
						layer.open({
							  title: '提示'
							  ,content: '成功激活'+res+'张卡片,请刷新页面查看'
							}); 
					}
				}); 
		 });
	}  
	/* 修改 */
	 function toUpdate(id){
		// 先读取接入数据，  修改接入数据
		$("#text_portToken").removeAttr("readonly");
		$("#text_portToken").css("border","1px green solid");
		$("#text_portAppkey").removeAttr("readonly");
		$("#text_portAppkey").css("border","1px green solid");
		$("#text_portAppsecret").removeAttr("readonly");
		$("#text_portAppsecret").css("border","1px green solid");
		$("#text_portUrl").removeAttr("readonly");
		$("#text_portUrl").css("border","1px green solid");
		$("#text_portPhone").removeAttr("readonly");
		$("#text_portPhone").css("border","1px green solid");
		
	 }
	 function portUpdate(id){
		// 先读取接入数据，  修改接入数据
		var  portToken = $("#text_portToken").val();
		var  portAppkey = $("#text_portAppkey").val();
		var  portAppsecret = $("#text_portAppsecret").val();
		var  portUrl = $("#text_portUrl").val();
		var  portPhone = $("#text_portPhone").val();
        $.ajax({
			url :"${base}/receive/portUpdate",
			type : 'post',
			dataType : 'json',
			data :{"id":id,"portToken":portToken,"portAppkey":portAppkey,
				"portAppsecret":portAppsecret,"portUrl":portUrl,"portPhone":portPhone},
			success : function(res) {
				layer.open({
					  title: '提示'
					  ,content: '修改成功,请刷新页面查看'
					});
				 $("#text_portToken").attr("readonly",true);
				 $("#text_portToken").css("border","0px black solid");
				 $("#text_portAppkey").attr("readonly",true);
				 $("#text_portAppkey").css("border","0px black solid");
				 $("#text_portAppsecret").attr("readonly",true);
				 $("#text_portAppsecret").css("border","0px black solid");
				 $("#text_portUrl").attr("readonly",true);
				 $("#text_portUrl").css("border","0px black solid");
				 $("#text_portPhone").attr("readonly",true);
				 $("#text_portPhone").css("border","0px black solid");
			}
		});
		
	 }
	function showDetail(id){
	 //通过id获取 该卡段信息
	 
		layer.open({
   			  type: 1,
   			  title: '卡段详情',
   			  shade: 0,
			  shadeClose: true,
   			  skin: 'layui-layer-rim', //加上边框
   			  area: ['1000px', '300px'], //宽高
   			  content: $('#detail')
   			});
		 $.ajax({
			url:"${pageContext.request.contextPath}/admin/cardReceive/detailById",
	        type:'post',
	        dataType:'json',
	        data:{'id':id},
	        success:function(res){

        		//debugger;
        		$("#detail_id").html(res.data.id);
            	$("#sequenceBegin").text(res.data.sequenceBegin);
            	$("#sequenceEnd").text(res.data.sequenceEnd);
            	$("#facePrice").html(res.data.facePrice);
            	$("#receiveCount").html(res.data.receiveCount);
            	$("#receiveName").html(res.data.receiveName);
            	$("#useCards").html(res.data.useCards);
            	$("#notUses").html(res.data.notUses1+res.data.notUses2);
            	$("#notActivation").html(res.data.notActivation);
            	$("#sequenceTime").html(res.data.sequenceTime);
            	$("#portToken").html("<input type='text' id='text_portToken' name='text_portToken' value='"+res.data.portToken+"' readOnly/>");
	            $("#portAppkey").html("<input type='text' id='text_portAppkey' name='text_portAppkey' value='"+res.data.portAppkey+"' readOnly/>");
	            $("#portAppsecret").html("<input type='text' id='text_portAppsecret' name='text_portAppsecret' value='"+res.data.portAppsecret+"' readOnly/>");
	            $("#portUrl").html("<input type='text' id='text_portUrl' name='text_portUrl' value='"+res.data.portUrl+"' readOnly/>");
	            $("#portPhone").html("<input type='text' id='text_portPhone' name='text_portPhone 'value='"+res.data.portPhone+"' readOnly/>");
	            $("#portUpdate").html("<a href='javascript:toUpdate("+res.data.id+");'>编辑</a>&nbsp;<a href='javascript:portUpdate("+res.data.id+");'>保存</a>");
            	if(res.data.notActivation != 0){
            		//activate()
            		var str = "&nbsp;&nbsp;<a href='javascript:activate("+res.data.sequenceBegin+","+res.data.sequenceEnd+");'>去激活</>";
            		$("#notActivation").html(res.data.notActivation+str);
            	}
        		layer.open({
       			  type: 1,
       			  title: '订单详情',
       			  shade: 0,
				  shadeClose: true,
       			  skin: 'layui-layer-rim', //加上边框
       			  area: ['1000px', '300px'], //宽高
       			  content: $('#order')
       			});
	        }
		}); 
	}

</script> 
</body>
</html>